﻿@{
    Layout = null;
    var user = ViewData["user"] as Pay.DTO.token_user_info;
    string img_url = ViewBag.img_url;

}
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>账号信息</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="~/Content/css/base.css" />
    <link rel="stylesheet" href="~/Content/css/tuoken.css" />
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/js/base.js"></script>
    <script src="~/Content/js/layer/1.9.3/layer.js"></script>
    <script src="~/Scripts/ajaxfileupload.js?v=1.0"></script>
</head>

<body>
    <div class="header">
        <a href="javascript:history.go(-1);">
            <span class="back"></span>
        </a>
        <div class="hdtitle">
            账号信息
        </div>
    </div>
    <div class="bodyct">
        <div class="property">
            <div class="setting">
                <a href="javascript:void(0);">头像<input class="upload" accept="image/*" type="file" id="upload" name="upload" /><img class="icon" id="photo" src="@(string.IsNullOrEmpty(user.photo)?"/content/images/my/smail.png":string.Format("{0}{1}", img_url,user.photo))" alt=""></a>

                <a href="javascript:void(0);" id="account_set">昵称<span class="nickname">@user.nick_name</span></a>
                <a href="javascript:void(0)" class="noico">账号<span class="nogray">@user.mobile</span></a>
                <a href="javascript:void(0)" class="noico">姓名<span class="nogray">@user.user_name</span></a>
                <a href="javascript:void(0)" class="noico">身份证<span class="nogray">@user.card_no</span></a>
                @*<a href="/MerchantBankCard/MyBankCard" class="noico">银行卡管理<span class="nogray"></span></a>*@
                <a href="/user/myadress" class="noico">收货地址管理<span class="nogray"></span></a>
                <a href="/user/help" class="noico">帮助中心<span class="nogray"></span></a>
            </div>
        </div>

        <!-- 修改昵称弹窗 -->
        <div class="mask"></div>
        <div class="update_nickname" id="update_nickname">
            <div class="content">
                <p>修改昵称</p>
                <div class="update_nicknamect">

                    <input type="text" name="" id="nickname" value="">
                    <input type="button" class="updatebtn" id="updatebtn" value="确认修改" onclick="setnickname()">


                </div>
            </div>
        </div>
    </div>

    <script>
        $(function () {
            $("#upload").on("change", function () {
                $.ajaxFileUpload({
                    url: '/user/Upload',//后台请求地址
                    type: 'post',//请求方式  当要提交自定义参数时，这个参数要设置成post
                    secureuri: false,//是否启用安全提交，默认为false。
                    fileElementId: 'upload',// 需要上传的文件域的ID，即<input type="file">的ID。
                    dataType: 'json',//服务器返回的数据类型。可以为xml,script,json,html。如果不填写，jQuery会自动判断。如果json返回的带pre,这里修改为json即可解决。
                    success: function (data, status) {//提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
                        var result = data.data;
                        if (data.result_code == 1000 && result.result) {
                            $("#photo").attr("src", result.path);

                        }
                        else {
                            layer.msg(data.result_msg);
                        }
                        $("#upload").val("");
                    },

                    error: function (data, status, e) {//提交失败自动执行的处理函数。
                        layer.msg("异常！");
                        $("#upload").val("");
                    }
                });
            });
        });
        function setnickname() {

            if ($("#nickname").val() == "") {
                layer.msg("请输入昵称");
            }
            else {
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "/User/UpdateNickName",//url
                    data: { Name: $("#nickname").val() },
                    success: function (result) {
                        if (result.result_code == 1000) {
                            layer.msg("修改成功");
                            location.reload()
                        } else {
                            layer.msg(result.result_msg);
                        }

                    },
                    error: function () {
                        layer.msg("异常！");
                    }
                });

            }
        }
        function fn() {
            if (!$("#nickname").val() == "") {
                $("#updatebtn").addClass('on')
            }
            else {
                $("#updatebtn").removeClass('on')
            }
        }

        $(function () {
            fn();
        })

        $("#nickname").on("input propertychange", function () {
            fn();
        })

        $("#account_set").click(function (event) {
            $(".mask").css("display", "block");
            $(".update_nickname").addClass('nickname_animation')
        });
        $(".mask").click(function (event) {
            $(".mask").css("display", "none");
            $(".update_nickname").removeClass('nickname_animation')
        });
    </script>
    @section scripts{
    }
</body>

</html>